class Solution {
public:
    vector<vector<int>> result;
    vector<int> path;
    void dfs(vector<int> &nums, int start_x) {
        result.push_back(path);
        for (int i = start_x; i < nums.size(); i++) {
            path.push_back(nums[i]);
            dfs(nums, i + 1);
            path.pop_back();
        }
        return ;
    }
    int subsetXORSum(vector<int>& nums) {
        dfs(nums, 0);
        int sum = 0;
        for (int i = 0; i < result.size(); i++) {
            int val = 0;
            for (auto x : result[i]) {
                val ^= x;
            }
            sum += val;
        }
        return sum;
    }
};
